﻿using System;
using System.Windows.Forms;
using System.IO;

namespace Lightray.Hattrick
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            try
            {
                Controller c = new Controller();
            }
            catch (Exception e)
            {
                MessageBox.Show("A fatal error has occured and iTrick must stop. A crash log will be written.", "Program Crash", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dumpCrashLog(e);
            }            
        }

        private static void dumpCrashLog(Exception e)
        {
            File.WriteAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),
                                           string.Format("Crash_{0}.log", DateTime.Now.ToString("ddMMyy__HHmmss"))),
                              e.ToString());                            
        }
    }
}
